//
//  HWIndexCell.m
//  嗨文
//
//  Created by 响当当 on 5/16/19.
//  Copyright © 2019 dongzheng. All rights reserved.
//

#import "HWIndexCell.h"

@interface HWIndexCell()
@property (nonatomic, strong)UILabel *titleLabel;
@property (nonatomic, strong)UILabel *timeLabel;
@property (nonatomic, strong)UIImageView *iconImageView;
@end

@implementation HWIndexCell

- (UILabel *)titleLabel
{
    if (!_titleLabel)
    {
        _titleLabel = [HWUtilties creatLabelWithFrame:CGRectMake(15*kUIScaleBasePlus,10*kUIScaleBasePlus,self.frame.size.width-30*kUIScaleBasePlus, 20*kUIScaleBasePlus)
                                         textAligment:NSTextAlignmentLeft
                                             textClor:[UIColor blackColor]
                                             textFont:15*kUIScaleBasePlus];
    }
    return _titleLabel;
}

- (UILabel *)timeLabel
{
    if (!_timeLabel)
    {
        _timeLabel = [HWUtilties creatLabelWithFrame:CGRectMake(15*kUIScaleBasePlus,CGRectGetMaxY(self.titleLabel.frame)+5*kUIScaleBasePlus,self.frame.size.width-30*kUIScaleBasePlus, 20*kUIScaleBasePlus)
                                         textAligment:NSTextAlignmentLeft
                                             textClor:LCHexColor(0x545454)
                                             textFont:14*kUIScaleBasePlus];
    }
    return _timeLabel;
}

- (UIImageView *)iconImageView
{
    if (!_iconImageView)
    {
        _iconImageView = [[UIImageView alloc]initWithFrame:CGRectMake(self.frame.size.width-5*kUIScaleBasePlus-18*kUIScaleBasePlus-60*kUIScaleBasePlus,self.frame.size.height/2,18*kUIScaleBasePlus,18*kUIScaleBasePlus)];
        
    }
    return _iconImageView;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.timeLabel];
        [self.contentView addSubview:self.iconImageView];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(15*kUIScaleBasePlus,CGRectGetMaxY(self.timeLabel.frame)+10*kUIScaleBasePlus,self.frame.size.width-100*kUIScaleBasePlus,0.5)];
        lineView.backgroundColor = JSALineColor;
        [self.contentView addSubview:lineView];
    }
    return self;
}

- (void)getIndexInfo:(HWIndexModel *)model
{
    self.titleLabel.text = model.chapterTitle;
    self.timeLabel.text = model.updateTime;
    
    
    if ([model.isReaded boolValue])
    {
        self.iconImageView.image = [UIImage imageNamed:@""];
    }
    else
    {
        self.iconImageView.image = [UIImage imageNamed:@"locked"];
    }
}
@end
